<template>
  <h1>Xss攻击</h1>
  <input_upload></input_upload>
  <!--<Toast></Toast>-->
  <input type="text" v-model="text">
  <button @click="addSubmit">评论</button>
  <!--<img src="23" onerror="alert('hahahahha 你呗攻击了')" alt="">-->
  <!--<button @click="show">显示评论</button>-->
  <ul>
    <li v-for="(item ,index) in msgList" :key="index">
      <!--v-html 有没有什么隐患 有可能被xss攻击-->
      <span v-html="item"></span>
    </li>
  </ul>
</template>

<script>
  import Toast from '../plugins/Toast.vue'
  export default {
    name: "Xss",
    components: {
      Toast
    },
    data() {
      return {
        text: '',
        msgList: []
      }
    },
    methods: {
      addSubmit() {
        let arr = [];
        arr = localStorage.getItem('item');
        arr = JSON.parse(arr);
        !arr && (arr = []);
        arr.push(this.text);
        this.msgList = arr;
        this.text = '';
        localStorage.setItem('item', JSON.stringify(arr));
      },
      // show() {
      //   let arr = localStorage.getItem('item');
      //
      // }
    }
  }
</script>

<style scoped>

</style>
